#!/bin/sh

#======================================================
# cvsrootmd5
# File ID: 006040ac-5d38-11df-9810-90e6ba3022ac
# Lagrer md5sum o.l. av cvsroot. Paranoia.
#======================================================

cfil=/home/sunny/src/cvs/p/cvsroot.md5
[ -d /home/sunny/cvsroot ] || { echo $0: Fant ikke cvsroot >&2; exit 1; }
pushd /home/sunny/cvsroot >/dev/null
datestr="$(date +"%Y-%m-%d %H:%M:%S %s") $(hostname)"
echo $datestr >$cfil
echo >>$cfil
find -type f -printf "%TY-%Tm-%Td %TH:%TM:%TS %8s %p\n" | sort -k4 >>$cfil
echo >>$cfil
find -type f -print0 | sort -z | xargs -0 md5sum >>$cfil
suuid -t cvsrootmd5 >$cfil.tmp
gpg --clearsign <$cfil >>$cfil.tmp || { echo $0: Feil under signering >&2; rm -f $cfil.tmp; exit 1; }
mv $cfil.tmp $cfil
popd >/dev/null
echo Trykk ENTER for cvs commit cvsroot.md5, eller CTRL-C for avbrudd.
read
pushd /home/sunny/src/cvs/p >/dev/null
cvs ci cvsroot.md5
popd >/dev/null
